# -*- coding: utf-8 -*-
# Author: xiantingDeng
# File: 05_property.py
# Time: 21:37

'''
class Demo(object):
    def __init__(self):
        self.__num = 100
        self._name = "小邓"


    def setNum(self, newNum):
        self.__num = newNum


    def getNum(self):
        return self.__num

    num = property(getNum,setNum) # 使用一个变量存储，调用两个函数


if __name__ == '__main__':
    demo = Demo()
    demo.num = 200 # 赋值时，调用的是setNum这个函数
    print(demo.num) # 读取时，则自动调用的是getNum这个函数
'''


class Demo(object):
    def __init__(self):
        self.__num = 100
        self._name = "小邓"

    @property
    def Num(self):
        return self.__num

    @Num.setter
    def Num(self, newNum):
        self.__num = newNum

if __name__ == '__main__':
    demo = Demo()
    demo.Num = 200
    print(demo.Num)